package com.cwj.film.service.impl;

import com.cwj.common.domain.film;
import com.cwj.film.Listener.Beans;
import com.cwj.film.service.inter.play;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class playImpl implements play {
    @Resource
    private Beans beans;

    @Override
    public List<String> GetFilmVideos(film film) {
        String videoPath = beans.getServerPath() + "film\\" + film.getType() +"\\"+ film.getTitle();
        File[] files = new File(videoPath).listFiles();
        if(files!=null) {
            return Arrays.stream(files).map(File::getName).collect(Collectors.toList());
        }else {
            return new ArrayList<>();
        }
    }

    @Override
    public void clickVideoAddRecord() {

    }


}
